﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MCYFlashApp
{
    public partial class FrmSwf : Form
    {
        int WM_KEYDOWN = 256;
        int WM_SYSKEYDOWN = 260;
        private string _currentFile = "";
        public FrmSwf()
        {
            InitializeComponent();
            this.Load += FrmSwf_Load;
        }

        public void SetFile(string filepath)
        {
            swfer.Movie = filepath;
            swfer.Play();

        }

        void FrmSwf_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_currentFile))
            {
                swfer.Movie = _currentFile;
                swfer.Play();
            }
           
        }

        public FrmSwf(string fileName)
        {
            InitializeComponent();
            _currentFile = fileName;
            this.Load += FrmSwf_Load;
        }

        private void FrmSwf_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.Escape:
                case Keys.C:
                    swfer.Stop();
                    swfer.Dispose();
                    this.Close();
                    break;
            }
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
            {
                switch (keyData)
                {
                    case Keys.Escape:
                    case Keys.C:
                        swfer.Stop();
                        swfer.Dispose();
                        this.Close();
                        break;
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }


    }
}
